<?php

namespace app\admin\logic;

use support\Backend\BackendLogic;
use support\Container;
use support\Exception\ApiException;
use support\Service\LinkService;

class LinkLogic extends BackendLogic
{

    public function __construct()
    {
        $this->service = Container::get(LinkService::class);
    }

    /**
     * 分页列表
     * @return array
     */
    public function getList(): array
    {
        $param = request()->all();
        $where = [];
        $where[] = ["mark", '=', 1];
        if (isset($param['name']) && $param['name']) {
            $where[] = ["name", 'like', "%{$param['name']}%"];
        }
        if (isset($param['type']) && $param['type']) {
            $where[] = ["type", '=', $param['type']];
        }
        if (isset($param['platform']) && $param['platform']) {
            $where[] = ["platform", '=', $param['platform']];
        }
        $list = $this->service->getListPage($where, ['*'], ['sort' => 'asc'], [], $param['limit'] ?? 10);
        return message($list);
    }


}
